import org.w3c.dom.Node;

import java.util.*;

public class Main {
    public static void main(String[] args) {

        char[] array = {'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'};
        String s3 = new String(array);
        System.out.println(s3);
    }

    //字符串拆分成数组，如”ab&&2”通过”&&”做分隔符，分割得到字符串数组[“ab”,”2”]
    public String[] split(String str) {
        int n = str.length();
        String[] s = new String[n];
        if (str == null || n == 0) return s;
        //转换字符数组
        char[] c = str.toCharArray();
        StringBuilder sb = new StringBuilder();
        int l = 0;
        for (int i = 0; i < n; i++) {
            if (c[i] > 'a' && c[i] < 'z' || c[i] > 'A' && c[i] < 'Z') {
                sb.append(c[i]);
            } else {
                s[l] = sb.toString();
                sb = new StringBuilder();
                l++;
            }
        }
        return s;
    }

    //实现字符串组合，如[“ab”,”2”]通过”&&”分隔符，组合成字符串”ab&&2”
    public String combination(String[] strs) {
        int n = strs.length;
        if (n == 0) return "";
        if (n == 1) return strs[0];
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(strs[i]);
            sb.append("&&");
        }
        return sb.toString();
    }

    //1000个整数，数值的范围是[0,999]，有且只有2个相同的数，请编写程序找出来
    public int[] same(int[] arr) {
        int[] ret = new int[2];
        int l = 0;
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < arr.length; i++) {
            map.put(arr[i], map.getOrDefault(arr[i], 0) + 1);
            if (map.get(arr[i]) == 2) {
                ret[l] = arr[i];
                l++;
            }
        }
        return ret;
    }

    //找出不大于n的最大质数
    public int primeNumber(int n) {


        for (int i = n - 1; i >= 0; i--) {
            int flag = 0;
            for (int j = n - 2; j > 1; j--) {
                int ret = i % j;
                if (ret == 0) {
                    flag = 1;
                    break;
                }
            }
            if (flag == 0) {
                return i;
            }
        }
        return 0;
    }


    // n个人(编号1~n)围成一圈从编号为1的开始报数，从1报数到m，报到m的人出来，
    // 下一个人继续重新从1开始报数，编程求最后一个留下的人的编号
    public int last(int n, int m) {

        List<Integer> list = new LinkedList<>();

        for (int i = 1; i <= n; i++) {
            list.add(i);
        }
        int index = 0;
        while (list.size() > 1) {
            index += m;
            if (index >= list.size()) {
                index = index - n;
            }
            list.remove(index - 1);
        }
        return list.get(0);
    }


}